package com.lxl.bt.activity;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;

import com.lxl.bt.R;
import com.yanzhenjie.sofia.Sofia;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Create by lvxinlong
 * on 协议
 **/
public class RuleWebviewActivity extends BaseActivity {


    @BindView(R.id.rlBack)
    RelativeLayout rlBack;
    @BindView(R.id.txt_toolbar_title)
    TextView txtToolbarTitle;

    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.tvTitle)
    TextView tvTitle;
    private Context context;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rule);
        ButterKnife.bind(this);
        context = this;
        Sofia.with(this)
                .invasionStatusBar()
                .statusBarDarkFont().statusBarBackgroundAlpha(0)
                .invasionNavigationBar().navigationBarBackgroundAlpha(0);
        txtToolbarTitle.setText("用户协议");
        rlBack.setVisibility(View.VISIBLE);
        tvTitle.setText(getYongHuTiaoKuanString(this));
    }
    public static String getYongHuTiaoKuanString(Context context) {
        StringBuilder termsString = new StringBuilder();
        BufferedReader reader;
        try {
            reader = new BufferedReader(
                    new InputStreamReader(context.getAssets().open("yinsixieyi.txt")));

            String str;
            while ((str = reader.readLine()) != null) {
                termsString.append(str);
                termsString.append("\n");
            }

            reader.close();
            return termsString.toString();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    @OnClick(R.id.rlBack)
    public void onViewClicked() {
        finish();
    }

}
